﻿namespace CodeGenerator.CSharp
{
    /// <summary>
    /// Defines a code unit for an operator.
    /// </summary>
    public class Operator : CodeUnit
    {
        public Operator(string name, ModifierCollection modifiers, string dataType) : base(name, modifiers) 
        { base.DataType = dataType; }

        public override string ToString()
        {
            CodeBuilder Code = new CodeBuilder();

            base.AppendDocumentation(Code);
            base.AppendAttributes(Code);

            Code.Add("{0}{1} {2} operator {3}({4})", this.Padding, this.Modifiers, this.DataType, this.Name, this.Parameters);
            Code.Add(base.Padding + "{");
            Code.Add(base.Body);
            Code.Add(base.Padding + "}");

            return Code.ToString();
        }

    }
}
